extends Sprite
class_name BaseEntity

var x:float = 200;
var y:float = 200;
var xv:float = 3
var yv:float = 3;


func _input(event):
    if(event is InputEventKey and event.is_pressed()):
        onKey(event);
    elif(event is InputEventMouseButton and event.is_pressed()):
        onMouse(event);
    

func onKey(event:InputEvent):
    var keyCode = event.scancode;

    if(keyCode == KEY_A):
        x = x - xv
    elif(keyCode == KEY_D):
        x = x + xv
    elif(keyCode == KEY_W):
        y = y - yv
    elif(keyCode == KEY_S):
        y = y + yv

    self.position = Vector2(x,y);

func onMouse(mouseEvt):
    if(mouseEvt.button_index == BUTTON_LEFT):
        self.position = mouseEvt.position;
